package com.mini.task;

import com.mini.constant.RedisKeyConst;
import com.mini.mysql.repository.BusinessBaseInfoRepository;
import com.mini.mysql.repository.BusinessStudentSecondOrderInfoRepository;
import com.mini.mysql.repository.BusinessStudentBigLessonXcxRepository;
import com.mini.mysql.service.BaseService;
import com.mini.mysql.service.BusinessStudentInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * @author shixiaopeng  on 2021/3/30
 */
@Service
@Slf4j
public class TaskAsyncBigLessonOrder extends BaseService {

    @Autowired
    private BusinessStudentInfoService businessStudentInfoService;
    @Autowired
    private BusinessBaseInfoRepository businessBaseInfoRepository;
    @Autowired
    private BusinessStudentBigLessonXcxRepository businessStudentBigLessonXcxRepository;
    @Autowired
    private BusinessStudentSecondOrderInfoRepository businessStudentSecondOrderInfoRepository;
    @Autowired
    private BaseService baseService;
    @Value("${spring.profiles.active}")
    private String profiles;

    @Scheduled(cron = "0/30 * * * * ?")
    public synchronized void asyncBigLessonXcxData() {
        if (profiles.contains("local") || profiles.contains("dev")) {
            return;
        }
//        String opreationLock = RedisKeyConst.getOpreationLock("big_lesson_xcx");
//        if(tryLock(opreationLock)) {
//            try{
//
//            }catch (Exception e){
//                releaseLockKey(opreationLock);
//                log.error("", e);
//                baseService.sendEmail("同步数据任务执行出错 ，请检查程序问题！");
//            }finally {
//                releaseLockKey(opreationLock);
//            }
//
//        }
    }
}
